package com.gmadmin.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gmadmin.entity.UnitPosition;
import com.gmadmin.mapper.UnitPositionMapper;
import com.gmadmin.service.UnitPositionService;
import com.gmadmin.service.vo.UnitPositionVo;
import com.gmadmin.utils.CollectionBeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UnitPositionServiceImpl extends ServiceImpl<UnitPositionMapper, UnitPosition> implements UnitPositionService {

    private final UnitPositionMapper mapper;

    public UnitPositionServiceImpl(UnitPositionMapper mapper) {
        this.mapper = mapper;
    }

    @Override
    public List<UnitPositionVo> getByUserId(Long id) {
        List<UnitPosition> unitPositions = mapper.selectByUserId(id);
        return CollectionBeanUtils.copyListProperties(unitPositions, UnitPositionVo::new);
    }

    @Override
    public List<UnitPositionVo> getPositions() {
        List<UnitPosition> unitPositions = mapper.selectList(null);
        return CollectionBeanUtils.copyListProperties(unitPositions, UnitPositionVo::new);
    }
}
